/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package database;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
import model.Dokument;
import model.Surat;

/**
 *
 * @author Adell
 */
public class SuratTabel extends AbstractTableModel {

    private String columns[] = {"NomorSurat", "Perihal", "AsalSurat", "Penerima", "Letak", "NamaPetugas", "TanggalTerima", "keterangan"};
    private ArrayList<Surat> data;

    public SuratTabel() {
    }

    public SuratTabel(ArrayList<Surat> data) {
        this.data = data;
    }

    @Override
    public int getRowCount() {
        return getData().size();
    }

    public String[] getColumns() {
        return columns;
    }

    @Override
    public int getColumnCount() {
        return getColumns().length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Surat sur = getData().get(rowIndex);
        if (columnIndex == 0) {
            return sur.getNomorSurat();
        } else if (columnIndex == 1) {
            return sur.getPerihal();
        } else if (columnIndex == 2) {
            return sur.getAsalSurat();
        } else if (columnIndex == 3) {
            return sur.getPenerimaSurat();
        } else if (columnIndex == 4) {
            return sur.getLetakSurat();
        } else if (columnIndex == 5) {
            return sur.getPetugasPenerimaSurat();
        } else if(columnIndex == 6){
            return sur.getTanggal();
        } else {
            return sur.getKeterangan();
        }
    }

    public void setColumns(String[] columns) {
        this.columns = columns;
    }

    public ArrayList<Surat> getData() {
        return data;
    }

    public void setData(ArrayList<Surat> data) {
        this.data = data;
    }
}
